function [X,A] = hmg_XfromPs(P,Pp,x,xp)

A = [crossMat(x)*P; crossMat(xp)*Pp];
[~,~,V] = svd(A);
X = V(:,end);

% Get orientation right
s = [P(3,:); Pp(3,:)]*X;
if any(s<0)
  X = -X;
  if any(s>0)
%    warning('Inconsistent orientation of point match');
  end
end

function A_x = crossMat(a)

  A_x = [ 0    a(3)  -a(2)
        -a(3)   0    a(1)
         a(2) -a(1)   0  ];